import { IOtaUpload } from '@/store/main/hardware/types'
import ftRequest from '../../index'

export function otaUpload(pageUrl: string, uploadInfo: IOtaUpload) {
  console.log('fffffffsssssss', uploadInfo.file)
  const fd = new FormData()
  if (uploadInfo.id) {
    fd.append('id', uploadInfo.id)
  }
  fd.append('productName', uploadInfo.productName)
  fd.append('productType', uploadInfo.productType)
  fd.append('firmwareVersion', uploadInfo.firmwareVersion)
  fd.append('hardwareGeneration', uploadInfo.hardwareGeneration)
  fd.append('updateUrl', uploadInfo.updateUrl)
  fd.append('updateTime', uploadInfo.updateTime)
  return ftRequest.post({
    url: pageUrl,
    data: fd
  })
}

export function newPageData(pageUrl: string, newData: any) {
  return ftRequest.post({
    url: pageUrl,
    data: newData
  })
}

export function editPageData(pageUrl: string, editData: any) {
  return ftRequest.post({
    url: pageUrl,
    data: editData
  })
}

export function getPageList(pageUrl: string) {
  return ftRequest.get({
    url: pageUrl,
    showLoading: false
  })
}
